<include file="header" />
<div class="wraper">
    <div class="user-info-container">
        <div class="user-info">
            <span class="block-space">
	            <if condition="$storeId neq 80">
		            <img class="logo" src="{BEESCRM:$data['store_logo']}"/>
	            </if>
	            </span>
            <a href="{BEESCRM::U('base/storeOld/rename',array('store_id'=>$storeId,'origin'=>$origin))}" class="user-name">
            	<if condition="$distributor">
            		{BEESCRM:$distributor['distributor_store_name']}
            	<else/>
            		{BEESCRM:$data['store_name']}
            	</if>
            	<if condition="(($did eq $fans_did) and $did) and (session('wechat_id') neq 13)">
            		<span class="iconfont icon-iconfontbianji"></span>
            	</if>
            </a>
        </div>
        <div class="user-menu clearfix">
            <a href="{BEESCRM::U('base/storeOld/goodsList',array('store_id'=>$storeId,'origin'=>$origin))}">
            	<span style="font-size: 16px">{BEESCRM:$data['count']}</span>
                <p>全部商品</p></a>
            <a href="javascript:void(0)" id="show-collect"><span class="iconfont icon-3"></span>
                <p>收藏本店</p></a>
            <!-- <a href="{BEESCRM::U('base/storeOld/qrcode',array('store_id'=>$storeId,'origin'=>$origin))}"><span class="iconfont icon-code_apply"></span>二维码</a> -->
        </div>
        <div class="photo">
        <img class="logo" <if condition="$distributor">src="{BEESCRM:$data['headImage']}"<elseif condition="$data['logo']"/>src="{BEESCRM:$data['logo']}"<else/>src="{BEESCRM:$data['wechat']['logo']}"</if>>
        
        </div>
    </div>
    <div class="search clearfix">
        <input class="pull-left" type="text" value="" placeholder="请输入商品关键词" id="keyword">
        <span class="iconfont icon-search pull-left"></span>
    </div>
    <div class="product-category clearfix">
    	<volist name="data['cate']" id="vo">
        <a class="lists category-lists pull-left" href="{BEESCRM::U('base/storeOld/goodsList',array('cate_id'=>$vo['cate_id'],'store_id'=>$storeId,'origin'=>$origin))}">
        	<img src="{BEESCRM:$vo['image']}"/>
        	<!-- <span>{BEESCRM:$vo['cate_name']}</span> -->
        </a>
		</volist>
    </div>
    <if condition="$data['flash']">
	    <div class="banner clearfix index-banner">
	        <div id="wrapper">
	            <div id="scroller">
	                <ul id="thelist">
	                	<volist name="data['flash']" id="vo">
	                    <li>
	                        <a href="{BEESCRM:$vo.url}"><img src="{BEESCRM:$vo.image}"/></a>
	                    </li>
	                    </volist>
	                </ul>
	            </div>
	        </div>
			<if condition="(($data['flash']) && (count($data['flash']) gt 1))">
		        <div id="nav" class="flash-class">
		            <div id="prev" onclick="myScroll.scrollToPage('prev', 0,400,3);return false">&larr; prev</div>
		            <ul id="indicator">
		            	<volist name="data['flash']" id="vo">
			                <li <eq name="key" value="1">class="active"</eq>>{BEESCRM:$key}</li>
		                </volist>
		            </ul>
		            <div id="next" onclick="myScroll.scrollToPage('next', 0,400,3);return false">next &rarr;</div>
		        </div>
	        </if>
	    </div>
	</if>
    <volist name="data['banner']" id="vo">
	    <a class="promote" href="{BEESCRM:$vo['url']}">
	        <img src="{BEESCRM:$vo['image']}"/>
	    </a>
    </volist>
    <!-- <div class="activity">
        <p class="title">超值优惠</p>
        <div class="activity-list-box clearfix">
            <a href="#" class="lists category-lists pull-left"><img src="/assets/store/common/images/activity-1.jpg"/></a>
            <a href="#" class="lists category-lists pull-left"><img src="/assets/store/common/images/activity-2.jpg"/></a>
            <a href="#" class="lists category-lists pull-left"><img src="/assets/store/common/images/activity-3.jpg"/></a>
            <a href="#" class="lists category-lists pull-left"><img src="/assets/store/common/images/activity-4.jpg"/></a>
        </div>
    </div> -->
    <div class="product">
        <a href="{BEESCRM::U('base/storeOld/goodsList',array('order'=>'recommend','store_id'=>$storeId,'origin'=>$origin))}" class="title">所有商品<span class="pull-right">更多 <span class="iconfont icon-you"></span></span></a>
        <volist name="data['goods']" id="vo">
        <a href="{BEESCRM::U('base/storeOld/goodsdetail',array('goods_id'=>$vo['goods_id'],'store_id'=>$storeId,'origin'=>$origin))}" class="tabulation clearfix">
            <div class="tabulation-img"><img src="{BEESCRM:$vo['goods_thumb']}"/></div>
            <div class="tabulation-info">
                <p class="tabulation-name">{BEESCRM:$vo['goods_name']}</p>
                <p class="prize"><span class="new-prize">￥{BEESCRM:$vo['goods_price']}</span><s class="old-prize">￥{BEESCRM:$vo['goods_original_price']}</s></p>
                <p><span class="discount">{BEESCRM:$vo['discount']}折</span><span class="sale">已售{BEESCRM:$vo['sale_num']}</span></p>
            </div>
        </a>
        </volist>
    </div>
    <div class="data-loding" style="display:none">数据加载中……</div>
</div>
<div class="pop-box clearfix" id="tishi">
    <p class="tips clearfix"><img class="pull-right" src="/assets/store/common/images/jiantou.png" ></p>
    <p>点击右上角，选择“收藏”<br/>加入收藏夹，方便您以后浏览！</p>
    <a href="javascript:;" class="i-know">知道了</a>
</div>

<input type="hidden" id="activitytime" value="">
<include file="Store:commonJs" />

<script type="text/javascript">
    if($('div').hasClass('flash-class') && $('#indicator li').length>1){
        var myScroll;
        function loaded() {
            myScroll = new iScroll('wrapper', {
                snap: true,
                momentum: false,
                hScrollbar: false,
                onScrollEnd: function () {
                	/* $('#indicator li').hasClass('active').removeClass('active'); */
                    document.querySelector('#indicator > li.active').className = '';
                    document.querySelector('#indicator > li:nth-child(' + (this.currPageX + 1) + ')').className = 'active';
                },
                vScroll: false,
                onBeforeScrollStart: function (e) {

                    if (this.options.hasTouch) {

                        point = e.touches[0];

                        pointStartX = point.pageX;

                        pointStartY = point.pageY;

                    }

                },

                onBeforeScrollMove: function (e) {

                    if (this.options.hasTouch) {

                        var point = e.touches[0];

                        deltaX = Math.abs(point.pageX - pointStartX);

                        deltaY = Math.abs(point.pageY - pointStartY);

                        if (deltaX >= deltaY) {

                            e.preventDefault();

                        }

                    }

                }
            });
        }
        document.addEventListener('DOMContentLoaded', loaded, false);

        var count = document.getElementById("thelist").getElementsByTagName("img").length;
        var img_width = document.body.clientWidth-20;
        for (i = 0; i < count; i++) {
            document.getElementById("thelist").getElementsByTagName("img").item(i).style.cssText = " width:" + img_width + "px";
        }
        document.getElementById("scroller").style.cssText = " width:" + document.body.clientWidth * count + "px";
        setInterval(function () {
            myScroll.scrollToPage('next', 0, 400, count);
        }, 3500);
        window.onresize = function () {
            for (i = 0; i < count; i++) {
                document.getElementById("thelist").getElementsByTagName("img").item(i).style.cssText = " width:" + img_width + "px";
            }
            document.getElementById("scroller").style.cssText = " width:" + document.body.clientWidth * count + "px";
        };
    }

    $(document).ready(function(){
        $('.icon-search').on('click',function(){
            var keyword=$('#keyword').val();
            if(keyword){
                window.location.href="{BEESCRM::U('base/storeOld/goodsList',array('store_id'=>$storeId,'origin'=>$origin))}/keyword/"+keyword;
            }else{
                alert('搜索条件为空');
            }
        });
    });
	
    $(document).on('click','#show-collect',function(){
    	$('#tishi').show();
    });
    
    $('.i-know').on('click',function(){
        $('#tishi').hide();
    });
</script>



<script type="text/javascript">
    $(document).ready(function(){
        var page = 2,
       		url="{BEESCRM:$url}",
                flag = true;

        $(window).scroll(function(){
            if(($(window).scrollTop() + $(window).height() > $(document).height() - 40)){
                    if(flag) {
                        flag = false;
                        $.ajax({
                            type:"GET",
                            url:url,
                            data:{'page': page},
                            dataType:'json',
                            beforeSend:function(){
                                $('.data-loding').show();//显示加载时候的提示
                            },
                            success:function(data){
                                $('.data-loding').hide();
                                var str ='';
                                if(data.status=='S'){
                                    if(data.data.length > 0) {
                                        $.each(data.data,function(i,k){
                                            str += "<a href='"+k.url+"' class='tabulation clearfix'><div class='tabulation-img'>"+
                                            "<img src='"+ k.goods_thumb+"'/>"+"</div><div class='tabulation-info'>"+
                                            "<p class='tabulation-name'>"+ k.goods_name+"</p>"+
                                            "<p class='prize'><span class='new-prize'>"+ k.goods_price+"</span><s class='old-prize'>"+ k.goods_original_price+"</s></p>"+
                                            "<p><span class='discount'>"+ k.discount+"折</span><span class='sale'>已售"+ k.sale_num+"</span></p></div></a>";
                                        });
                                        $(".product").append(str);
                                        page++;
	                                    flag = true;
                                    } else {
                                        $('.data-loding').hide();
	                                    flag = false;
                                    }
                                }
                            }
                        });
                    }
            }
        })
    })
</script>
<include file="footer" />

